#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include<QCloseEvent>
#include<qobject.h>
#include<QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->a0->installEventFilter(this);

}

MainWindow::~MainWindow()
{
    QMessageBox::information(this,"OVER","OVER");
    delete ui;
}


bool MainWindow::event(QEvent *e){



    switch (e->type()) {
    case QEvent::Close:
        closeEvent(dynamic_cast<QCloseEvent*>(e));
        qDebug()<<"close event" ;
        break;
    case QEvent::MouseMove:
        mouseMoveEvent(dynamic_cast<QMouseEvent*>(e));
        qDebug()<<"mouse event";

        break;
    case QEvent::MouseButtonPress:
        mouseMoveEvent(dynamic_cast<QMouseEvent*>(e));
        qDebug()<<"mouse button pressed";
        break;
    }

    return QMainWindow::event(e);
}



bool MainWindow::eventFilter(QObject *watched, QEvent *event){

    qDebug()<<"eventFilter";
    qDebug()<< (watched == ui->a0);

    return QMainWindow::eventFilter(watched,event);
}













